    //
//  MainViewController.m
//  NumLot
//
//  Created by luotao on 12-8-12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "MainViewController.h"
#import "Cons.h"

@implementation MainViewController

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/


// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	[super loadView];
    //加载背景图片
	[self loadBgImage];
	//加载内容view
	[self loadContentView];	
	
}

-(void)loadContentView{
    
	topViewController = [[TopViewController alloc] init];
	
	contentViewController = [[ContentViewController alloc]init];
	
	buttomViewController = [[ButtomViewController alloc]init];
	
    [self.view addSubview:topViewController.view];
	
	[self.view addSubview:contentViewController.view];
	
	[self.view addSubview:buttomViewController.view];

	[contentViewController addMoveListener:topViewController];
	
	[buttomViewController addControllerListener:contentViewController];
		
		
}


-(void) loadBgImage{
	CGRect screen=[[UIScreen mainScreen]applicationFrame];
	if(LOG_DEBUG){
		NSLog(@"screen : %f",screen.size.width);
	}	
	UIImageView *bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg.png"]];
	
	bgImageView.frame=screen;
	
	[self.view addSubview:bgImageView];
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	
//	self.view.userInteractionEnabled=YES;
	
//	NSLog(@"user : %d",self.view.userInteractionEnabled);
//	UIButton *button =  [UIButton buttonWithType:UIButtonTypeRoundedRect];
//	button.frame= CGRectMake(20, 200, 100, 100);	
//	button.userInteractionEnabled=YES;
//	[button setTitle:@"OK123" forState:UIControlStateNormal];
	
	
//	[button addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
//
//	[self.view addSubview:button];}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
}
- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[self.view release];
	[topViewController release];
	[ContentViewController release];
	[buttomViewController release];
    [super dealloc];
}


@end
